// pages/release_evaluation/release_evaluation.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pro_id:'',
    good:{},
    content:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  plC: function (e) {
    this.setData({
      content: e.detail.value
    })
  },
  sendPl: function () {
    let that = this
    console.log(2222)
    if (that.data.content == '') {
      wx.showToast({
        title: '请输入评论内容',
        icon: 'none',
        duration: 2000
      })
    }
    else {
      wx.request({
        url: app.globalData.url + 'ziyu.php?Action=hangqingpinglun',
        data: {
          goods_id: that.data.pro_id,
          openid: app.globalData.opid,
          content: that.data.content
        },
        header: {
          'content-type': 'application/json' // 默认值
        },
        success: function (res) {
         console.log(res)
         if(res.data.success == 2){
           wx.showToast({
             title: res.data.msg,
             mask: true,
             icon: 'none',
           })
           setTimeout(function(){
            wx.navigateBack();
          },1000)
         }else{
           wx.showToast({
             title: '评论成功',
             mask: true,
             icon: 'none',
           })
          setTimeout(function(){
            wx.navigateBack();
          },1000)
         }
        
          
        }
      })
    }
  },
  onLoad: function (options) {
    var that = this;
    if(options.id){
      that.setData({
        pro_id:options.id
      })

      wx.request({
        url: 'https://rt.gzziyu.com//mobile/ny_flow_goods.php?action=detail',
        data:{
          goods_id: that.data.pro_id
        },
        success:function(res){
          console.log(res)
          that.setData({
            good:res.data
          })
        }
      })
    }


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})